package com.cxy.view.service;

import com.cxy.view.mapper.ViewMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class BoxOfficeService {
    private final ViewMapper viewMapper; // 注入ViewMapper

    @Autowired // 显式添加依赖注入注解
    public BoxOfficeService(ViewMapper viewMapper) {
        this.viewMapper = viewMapper;
    }

    public Map<String, Object> getBoxOfficeStatistics() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("totalBoxoffice", viewMapper.sumTotalBoxoffice() != null ? viewMapper.sumTotalBoxoffice() : 0.0);
        stats.put("todayBoxoffice", viewMapper.sumTodayBoxoffice() != null ? viewMapper.sumTodayBoxoffice() : 0.0);
        return stats;
    }

    public Map<String, Object> getBoxOfficeStatistics2() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("totalTickets", viewMapper.sumTotalTickets() != null ? viewMapper.sumTotalTickets() : 0.0);
        stats.put("todayTickets", viewMapper.sumTodayTickets() != null ? viewMapper.sumTodayTickets() : 0.0);
        return stats;
    }


}